package org.qpcr.community.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

@Getter
@Setter
@Table(name = "biz_log_message")
@Comment("用户操作日志信息表")
@EnableEntityEvent
public class LogMessageEntity extends GenericEntity<String> {

    @Override
    @Id
    @Column(length = 64, updatable = false)
    @GeneratedValue(generator = Generators.SNOW_FLAKE)
    @NotBlank(message = "ID不能为空", groups = CreateGroup.class)
    @Pattern(regexp = "^[0-9a-zA-Z_\\-|]+$", message = "ID只能由数字,字母,下划线和中划线组成", groups = CreateGroup.class)
    public String getId() {
        return super.getId();
    }


    @Schema(description = "用户名称")
    @Column(name = "name", length =50)
    private String name;

    @Schema(description = "业务分类")
    @Column(name = "type", length =50)
    private Integer type;



    @Schema(description = "模块编号")
    @Column(name = "module_code", length = 64)
    private String moduleCode;

    @Schema(description = "设备id")
    @Column(name = "device_id", length = 64)
    private String deviceId;

    @Schema(description = "设备名称")
    @Column(name = "device_name", length = 100)
    private String deviceName;

    @Schema(description = "日志说明")
    @Column(name = "description", length = 200)
    private String description;




    @Column(updatable = false)
    @Schema(
        description = "创建者ID(只读)"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private String creatorId;

    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(
        description = "创建时间(只读)"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private Long createTime;
}
